package com.digitalchina.lxnsy.api;

import android.app.Activity;
import android.os.Handler;

import com.digitalchina.lxnsy.constant.MSG;
import com.digitalchina.lxnsy.constant.URL;
import com.digitalchina.lxnsy.toolkit.EncryptUtil;
import com.digitalchina.lxnsy.toolkit.OkHttpUtil;
import com.digitalchina.lxnsy.xml.UserXML;
import com.lzy.okhttputils.model.HttpParams;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.api
 * 创建人：郑皓
 * 创建时间：2018/10/9 18:43
 * 修改备注：
 * ================================================
 */
public class BusinessWallet {

    /**
     * 电子钱包余额
     *
     * @param activity
     * @param handler  result：
     *                 actualBal    余额
     *                 freezeMoney 总共冻结保障金(忽略）
     *                 canUseBal  可用余额
     */
    public static void getBalance(Activity activity, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userAccId", UserXML.getUserId(activity));

        OkHttpUtil.post(activity, URL.URL_GET_BALANCE, "", params, handler, MSG.MSG_GET_BALANCE_SUCCESS, MSG.MSG_GET_BALANCE_FIELD);

    }

    /**
     * 银行卡列表
     *
     * @param activity
     * @param handler
     */
    public static void bankCardList(Activity activity, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userAccId", UserXML.getUserId(activity));

        OkHttpUtil.post(activity, URL.URL_BANK_CARD_LIST, "", params, handler, MSG.MSG_BANK_CARD_LIST_SUCCESS, MSG.MSG_BANK_CARD_LIST_FIELD);

    }


    /**
     * 添加银行卡
     *
     * @param activity
     * @param userName   银行卡真实姓名
     * @param bankName   银行卡名称
     * @param cardNumber 银行卡号
     * @param branchName 开户行
     * @param handler
     */
    public static void addBankCard(Activity activity, String userName, String bankName, String cardNumber, String branchName, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userAccId", UserXML.getUserId(activity));
        params.put("userName", userName);
        params.put("bankName", bankName);
        params.put("cardNumber", cardNumber);
        params.put("branchName", branchName);

        OkHttpUtil.post(activity, URL.URL_ADD_BANK_CARD, "", params, handler, MSG.MSG_ADD_BANK_CARD_SUCCESS, MSG.MSG_ADD_BANK_CARD_FIELD);

    }

    /**
     * 删除银行卡
     *
     * @param activity
     * @param id       银行卡ID
     * @param handler
     */
    public static void deleteBankCard(Activity activity, String id, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("id", id);

        OkHttpUtil.post(activity, URL.URL_DELETE_BANK_CARD, "", params, handler, MSG.MSG_DELETE_BANK_CARD_SUCCESS, MSG.MSG_DELETE_BANK_CARD_FIELD);

    }


    /**
     * 提现-银行卡
     *
     * @param activity
     * @param paymentPwd 支付密码
     * @param payAmt     提现金额
     * @param bankCardId 银行卡ID
     * @param handler
     */
    public static void withdrawCashForBank(Activity activity, String paymentPwd, String payAmt, String bankCardId, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userAccId", UserXML.getUserId(activity));
        params.put("paymentPwd", EncryptUtil.SHA1(paymentPwd));
        params.put("withdrawWay", "0"); // 银行卡 0 支付宝 1
        params.put("payAmt", payAmt);
        params.put("bankCardId", bankCardId);

        OkHttpUtil.post(activity, URL.URL_WITHDRAW_CASH, "", params, handler, MSG.MSG_WITHDRAW_CASH_SUCCESS, MSG.MSG_WITHDRAW_CASH_FIELD);

    }

    /**
     * 提现-支付宝
     *
     * @param activity
     * @param paymentPwd    支付密码
     * @param payAmt        提现金额
     * @param userName      支付宝姓名
     * @param accountNumber 支付宝账号
     * @param handler
     */
    public static void withdrawCashForAlipay(Activity activity, String paymentPwd, String payAmt, String userName, String accountNumber, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userAccId", UserXML.getUserId(activity));
        params.put("paymentPwd", EncryptUtil.SHA1(paymentPwd));
        params.put("withdrawWay", "1"); // 银行卡 0 支付宝 1
        params.put("payAmt", payAmt);
        params.put("userName", userName);
        params.put("accountNumber", accountNumber);

        OkHttpUtil.post(activity, URL.URL_WITHDRAW_CASH, "", params, handler, MSG.MSG_WITHDRAW_CASH_SUCCESS, MSG.MSG_WITHDRAW_CASH_FIELD);

    }

    /**
     * 提现记录列表
     *
     * @param activity
     * @param page
     * @param limit
     * @param handler
     */
    public static void withdrawList(Activity activity, int page, int limit, Handler handler) {

        HttpParams params = new HttpParams();
        params.put("userAccId", UserXML.getUserId(activity));
        params.put("page", String.valueOf(page));
        params.put("limit", String.valueOf(limit));

        OkHttpUtil.post(activity, URL.URL_WITHDRAW_LIST, "", params, handler, MSG.MSG_WITHDRAW_LIST_SUCCESS, MSG.MSG_WITHDRAW_LIST_FIELD);

    }

}
